/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Util;

import objectreader.test.TestMultipleModelViewer;

/**
 *
 * @author Eduardo
 */
public class ComePeca implements TimerListener
{
    int x, y;
    double incY, div, cont;
    long millis;
    TestMultipleModelViewer tela;
    Timer timer;

    public ComePeca (int x, int y, long millis, TestMultipleModelViewer tela)
    {
        this.cont = 0.0;
        this.div = 20.0;
        this.incY = 0.1;
        this.x = x;
        this.y = y;
        this.tela = tela;
        this.tela.movY2 = 0.0;
        timer = new Timer(this,millis);
    }

    public void comer()
    {
        timer.start();
    }

    public void update(long millis)
    {
        if (cont == div - 1.0)
        {
            timer.finalizar();
            tela.pecaSendoComida = -2;
            tela.tabuleiro[x][y] = -1;
        }
        else
        {
            tela.movY2 -= incY;
            cont += 1.0;
            tela.repaint();
        }
    }
}
